package com.seadragon.apps.doctorcard.model;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.Type;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.DateSerializer;
import com.vividsolutions.jts.geom.Point;

@Entity
@Table(name = "friend")
public class Friend implements Serializable {
	private static final long serialVersionUID = 3663603047553980592L;

	@Id
	@Column(name = "ID")
	@GeneratedValue(strategy = GenerationType.AUTO)
	private long id;

	@ManyToOne
	@JoinColumn(name="SENDER_ID")
	private Contact sender;

	@ManyToOne
	@JoinColumn(name="RECIPIENT_ID")
	private Contact recipient;

	@Column(name = "RECIPIENT_ALIAS")
     private Point recipientAlias;

	@Column(name = "SENDER_ALIAS")
    private String senderAlias;

	@Column(name = "LOCATION")
    @Type(type = "org.hibernate.spatial.GeometryType")
    private Point location;

	@JsonSerialize(using = DateSerializer.class)
	@Column(name="DATE_CONNECTED")
	private Date dateConnected;

	public Friend(){}
	
	public Friend(long friendId){
		this.id = friendId;
	}
	public Friend(Contact sender, Contact recipient){
		this.sender = sender;
		this.recipient = recipient;
	}
	
	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public Date getDateConnected() {
		return dateConnected;
	}

	public void setDateConnected(Date dateConnected) {
		this.dateConnected = dateConnected;
	}

	public Contact getSender() {
		return sender;
	}

	public void setSender(Contact sender) {
		this.sender = sender;
	}

	public Contact getRecipient() {
		return recipient;
	}

	public void setRecipient(Contact recipient) {
		this.recipient = recipient;
	}

	public Point getLocation() {
		return location;
	}

	public void setLocation(Point location) {
		this.location = location;
	}

	public Point getRecipientAlias() {
		return recipientAlias;
	}

	public void setRecipientAlias(Point recipientAlias) {
		this.recipientAlias = recipientAlias;
	}

	public String getSenderAlias() {
		return senderAlias;
	}

	public void setSenderAlias(String senderAlias) {
		this.senderAlias = senderAlias;
	}

}
